#!/usr/bin/env node

const Router = require('koa-router'),
      bodyparser = require('koa-bodyparser');

const router = new Router();

//  app.use(bodyparser({enableTypes:['json', 'form', 'text']}));

router.prefix('/api/authors');

  router.get('/', async(ctx)=>{
    const {page,limit} = ctx.query;
    //console.log(ctx.headers);
    ctx.body = ` ${ctx.header}  分页查询漫画书,page=${page}&limit=${limit}`;
  })

  router.get('/:authorName', async(ctx)=>{
    const {authorName} = ctx.params;
    ctx.body=`按名字查询漫画书,authorName=${authorName}`;
  })

  router.post('/',async(ctx)=>{
    const {authorName} = ctx.request.body;
    ctx.body = `添加新的漫画书,authorName=${authorName}`;
  })

  router.put('/:id', async(ctx)=>{
    const {id} = ctx.params;
    ctx.body = `修改,id=${id}`;
  })

  router.delete('/:id',async(ctx)=>{
    const {id} = ctx.params;
    ctx.body=`删除,id=${id}`;
  })

module.exports = router;

